<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title>性能测试</title>


  <style type="text/css">
@import url("css/function.css");
  </style>
</head>



<body>

<h1 id="htitle"> 性能测试 </h1>

<a href="index.html">返回主索引</a>
<hr><!--"----------------------------------------"-->
<p>有
一个性能测试工具可以检测Geosings运行的情况和各个部分所花时间。</p>

<p>工具在GEOSINGS_HOME/bin目录下，有两个，一个是gssprof.py，一个是profreader.py。</p>

<p>其中gssprof.py是直接运行主界面程序的。通过运行，会生成一个叫prof.plog的文件。这个文件中记录了所有模块和函数
的用时情况。但是是一个二进制文件。而profreader.py文件就是为了读取这个二进制文件的。</p>

<p>
通过传入profreader.py的参数，可以用来控制输出哪个模块的报告输出。比如要测试LayerCanvas.py这个模块的参数，就输入
profreader.py LayerCanvas就可以了。如果没有参数，就输出所有的报告。</p>

<p>比如这样一个报告：</p>
<p></p>
<table style="text-align: left; width: 100%;" border="1" cellpadding="2" cellspacing="2">
  <tbody>
    <tr>
      <td style="background-color: rgb(215, 219, 255);">Wed May 30 14:20:18 2007&nbsp;&nbsp;&nbsp;
prof.plog<br>

      <br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
10261 function calls (10198 primitive calls) in 3.029 CPU seconds<br>

      <br>

&nbsp;&nbsp; Ordered by: internal time<br>

&nbsp;&nbsp; List reduced from 1742 to 4 due to restriction
&lt;'LayerCanvas.py'&gt;<br>

      <br>

&nbsp;&nbsp; ncalls&nbsp; tottime&nbsp;
percall&nbsp; cumtime&nbsp; percall filename:lineno(function)<br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1&nbsp;&nbsp;&nbsp; 0.002&nbsp;&nbsp;&nbsp;
0.002&nbsp;&nbsp;&nbsp; 0.003&nbsp;&nbsp;&nbsp;
0.003 LayerCanvas.py:6(?)<br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1&nbsp;&nbsp;&nbsp; 0.000&nbsp;&nbsp;&nbsp;
0.000&nbsp;&nbsp;&nbsp; 0.000&nbsp;&nbsp;&nbsp;
0.000 LayerCanvas.py:29(VectorCanvas)<br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1&nbsp;&nbsp;&nbsp; 0.000&nbsp;&nbsp;&nbsp;
0.000&nbsp;&nbsp;&nbsp; 0.000&nbsp;&nbsp;&nbsp;
0.000 LayerCanvas.py:13(LayerCanvas)<br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1&nbsp;&nbsp;&nbsp; 0.000&nbsp;&nbsp;&nbsp;
0.000&nbsp;&nbsp;&nbsp; 0.000&nbsp;&nbsp;&nbsp;
0.000 LayerCanvas.py:260(RasterCanvas)<br>

      <br>

      <br>

press enter to exit...</td>
    </tr>
  </tbody>
</table>
<p></p>

<p><br>
</p>

<p>可以参考<a href="http://blog.csdn.net/lanphaday/archive/2007/01/15/1483728.aspx">这里</a>。</p>
<p><span> profile</span>的统计结果分为ncalls, tottime, percall, cumtime, percall, filename:lineno(function)等若干列：</p>
<table style="border: medium none ; background: rgb(204, 153, 255) none repeat scroll 0% 50%; -moz-background-clip: initial; -moz-background-origin: initial; -moz-background-inline-policy: initial; border-collapse: collapse;" bgcolor="#cc99ff" border="1" cellpadding="0" cellspacing="0">
    <tbody>
        <tr>
            <td style="border: 0.5pt solid windowtext; padding: 0cm 5.4pt; width: 122.4pt;" valign="top" width="163">            
      <div><span style="color: white;">ncalls</span></div>
            </td>
            <td style="border-style: solid solid solid none; border-color: windowtext windowtext windowtext -moz-use-text-color; border-width: 0.5pt 0.5pt 0.5pt medium; padding: 0cm 5.4pt; width: 303.7pt;" valign="top" width="405">            
      <div><span style="color: white;">函数的被调用次数</span></div>
            </td>
        </tr>
        <tr>
            <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 0.5pt 0.5pt; padding: 0cm 5.4pt; width: 122.4pt;" valign="top" width="163">            
      <div><span style="color: white;">tottime</span></div>
            </td>
            <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 0.5pt 0.5pt medium; padding: 0cm 5.4pt; width: 303.7pt;" valign="top" width="405">            
      <div><span style="color: white;">函数总计运行时间，除去函数中调用的函数运行时间</span></div>
            </td>
        </tr>
        <tr>
            <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 0.5pt 0.5pt; padding: 0cm 5.4pt; width: 122.4pt;" valign="top" width="163">            
      <div><span style="color: white;">percall</span></div>
            </td>
            <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 0.5pt 0.5pt medium; padding: 0cm 5.4pt; width: 303.7pt;" valign="top" width="405">            
      <div><span style="color: white;">函数运行一次的平均时间，等于</span><span style="color: white;">tottime/ncalls</span></div>
            </td>
        </tr>
        <tr>
            <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 0.5pt 0.5pt; padding: 0cm 5.4pt; width: 122.4pt;" valign="top" width="163">            
      <div><span style="color: white;">cumtime</span></div>
            </td>
            <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 0.5pt 0.5pt medium; padding: 0cm 5.4pt; width: 303.7pt;" valign="top" width="405">            
      <div><span style="color: white;">函数总计运行时间，含调用的函数运行时间</span></div>
            </td>
        </tr>
        <tr>
            <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 0.5pt 0.5pt; padding: 0cm 5.4pt; width: 122.4pt;" valign="top" width="163">            
      <div><span style="color: white;">percall</span></div>
            </td>
            <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 0.5pt 0.5pt medium; padding: 0cm 5.4pt; width: 303.7pt;" valign="top" width="405">            
      <div><span style="color: white;">函数运行一次的平均时间，等于</span><span style="color: white;">cumtime/ncalls</span></div>
            </td>
        </tr>
        <tr>
            <td style="border-style: none solid solid; border-color: -moz-use-text-color windowtext windowtext; border-width: medium 0.5pt 0.5pt; padding: 0cm 5.4pt; width: 122.4pt;" valign="top" width="163">            
      <div><span style="color: white;">filename:lineno(function)</span></div>
            </td>
            <td style="border-style: none solid solid none; border-color: -moz-use-text-color windowtext windowtext -moz-use-text-color; border-width: medium 0.5pt 0.5pt medium; padding: 0cm 5.4pt; width: 303.7pt;" valign="top" width="405">            
      <div><span style="color: white;">函数所在的文件名，函数的行号，函数名</span></div>
            </td>
        </tr>
    
  </tbody>
</table>
<div>&nbsp;<br>
这个模块里所有的函数运行时间和运行次数都列出来了。这样可以知道我们这个程序的运行瓶颈在什么地方。以便后期开发的修补。</div>

<hr><!--"----------------------------------------"--><br>

<table id="etab">

  <tbody>

    <tr>

      <td id="etit">geosings, 性能测试</td>

      <td id="ereta"><a href="index.html">返回主目
录</a></td>

    </tr>

  </tbody>
</table>

</body>
</html>
